<script>
$(document).ready(function(){
	$('#view_date').datepicker({ dateFormat: 'yy-mm-dd' });
	$('#expected_date').datepicker({ dateFormat: 'yy-mm-dd' });
	
})
$(function() {
	     var scntDiv = $('#p_scents');
        var i = $('#p_scents tr').size() + 1;
        
        $('.addScnt').live('click', function() {
                $('<tr style="background-color:#D1E4FC;" id="dd'+ i +'"> <td><input type="text"   name="name[]" id="name'+i+'" /></td><td><input type="text"   name="category[]" id="category'+i+'" /></td><td><input type="text"   name="company[]" id="company'+i+'" /></td><td><input type="text" class="span2" name="quantity[]" id="quantity'+ i +'"  /></td> <td><a href="#" class="addScnt"><img src="<?php echo base_url()?>/assets/images/plus1.png"  width="15" height="15" ></a>&nbsp;&nbsp;&nbsp;<a href="#"  id="'+i+'" class="remScnt"><img src="<?php echo base_url()?>/assets/images/minus3.png"  width="15" height="15" ></a></td></tr>').appendTo(scntDiv);
                i++;
                return false;
        });
		 $('.remScnt').live('click', function() { 
		//alert(i)
		    if( i > 2 ) {
                        
						$(this).parents('tr').remove();
                        i--;
                }
                return false;
        });
        
        
});
 
function get_product(code){
	$.post("<?= site_url('enquiry/enquiry/get_productName')?>",{ code:code }, function(msg){
		if(msg){
			$('#product_name').val(msg)
			}else{
				$('#product_name').val(""),
				alert('No Product Is Available!!')
				}
		
		})
	
	}
	
function get_product1(code,rate){
		var id="#"+$(rate).attr('id')
		$.post("<?= site_url('enquiry/enquiry/get_productName')?>",{ code:code }, function(msg){
		if(msg){
				$(id).val(msg);	

			}else{
				$(id).val(""),
				alert('No Product Is Available!!')
				}
		
		})
	
}	

function form_valid(){
	
if($('#id_supplier').val()=='0'){
	alert('Select A Supplier!')
	return false
	
}

}

 
</script>
<h2 style="background-color:#368EE0; color:white; font-size:20px; padding:5px;">ADD Order </h2>
<form action="<?= site_url('purchase_order/order/add_order')?>" method="post" onsubmit="return form_valid()">
<!--<div id="infoMessage"><?php echo $message;?></div>-->
<table align="center">
<tr><td><br>SUPPLIER</td><td>
            <?php 
	 	$bl[0] = "--Select Supplier--";
	   		foreach($suppliers as $supplier){
				$bl[$supplier->id] = $supplier->name;
			}
			echo form_dropdown('id_supplier', $bl, '', 'class="chzn-select " id="id_supplier" data-placeholder="Choose a Customer" name="id_customer" id="id_customer" style="width:220px;"');  ?>
	
<a href="<?=site_url('people/supplier/create_supplier/st')?>" ><i class="icon-edit"></i></a> 
</td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>

<tr>
<td>ENQUIRY NO</td> <td><?php echo form_input($order_no);?></td>
</tr>  
<tr>      
<td>DATE</td><td><?php echo form_input($view_date);?></td>
</tr>
<tr>      
<td>EXPECTED DATE</td><td><?php echo form_input($expected_date);?>  </td>
</tr>
</table>
<hr>


<table width="100%" class="table table-bordered" >

  <tr style="background-color:#F6F6F6;" >
            	<td><b>Product Name</b></td>
			    <td><b>Category Name</b></td>
			  	<td><b>Company Name</b></td>
             	<td><b>Quantity</b></td>
				<td><b>Option</b></td>
			 </tr>
 <tbody id="p_scents">           
  <tr style="background-color:#D1E4FC;"><label for="p_scnts">
    <td><input type="text"  name='name[]'  id="name" /></td>
	 <td><input type="text"  name='category[]'  id="category" /></td>
	  <td><input type="text"  name='company[]'  id="company" /></td>
    <td><input type="text" class="span2" id="quantity" name='quantity[]'/></td>
<td><a href="#" class="addScnt"><img src="<?php echo base_url()?>/assets/images/plus1.png"  width="15" height="15" ></a></td>
 </label> </tr>
  </tbody>
</table>
<p align="right"><?php echo form_submit('submit', 'Purchase Order', 'class="btn btn-info"');?></p>
</form>
<!--<?php echo form_close();?>-->
